import Vue from 'vue'
import Vuex from 'vuex'

// 导入全局模块
import actions from './actions';
import getters from './getters';
import mutations from './mutations';

// 导入模块
import fold from './modules/fold';
import operation from './modules/operation';
import account from './modules/account';
import route from './modules/route';
import menu from './modules/menu';
import icon from './modules/icon';
import role from './modules/role';

// 持久化插件
import createPersistedState from 'vuex-persistedstate';

// 插件
Vue.use(Vuex)

let store = new Vuex.Store({
  modules: {
    fold,
    operation,
    account,
    route,
    menu,
    icon,
    role,
  },
  state: {
  },
  getters,
  mutations,
  actions,
  plugins: [
    // 推荐将vuex的数据存储到sessionStorage，浏览器关闭数据消失；(调试完项目也可以改成localStorage；)
    createPersistedState({
      storage: window.sessionStorage,
    }),
  ],
});

export default store
